<% if @tasks.size == 0 -%>
No tasks. To add a task, click 'New Task'<br/>
<br/>
<% end -%>

<%
sel_task_id = session[:selected_task].to_i
children = @tasks.select {|t| t.task_id==sel_task_id}
%>

<%= pluralize(@tasks.size, "task")%><br/>
<input class="button" type="button" onclick="add_new_row();return false;" onmouseover="mover('a')" onmouseout="mover('')" value="New Task">
<img id="loading" src="/images/loading.gif" style="display:none;"><br/>

<a href="#" title="display root tasks" onclick="$('loading').show();disp_sub(0);return false;"><img src="/images/sitemap-green.gif"></a>

<%
if(sel_task_id != 0)
  sel_task = Task.find(sel_task_id)
-%>
  <a href="#" title="go up" onclick="$('disp_up').src='/images/loading.gif';disp_sub(<%=sel_task.task_id%>);return false;"><img id="disp_up" src="/images/disp_up.gif"></a>
  <%= render(:partial => "task_title", :object => sel_task) %>
<% end -%>

<% form_tag({:action=> :post}, {:name => 'tasksform'}) do %>

<!-- Tasks -->

<ul id="taskslist" class="sortablelist">
<% #by_tag = nil
if(by_tag!=nil) %>
<%= render(:partial => "task", :collection => @tasks, :locals=>{:tasks=>@tasks}) %>
<% else %>
<%= render(:partial => "task", :collection => children, :locals=>{:tasks=>@tasks}) %>
<% end %>
</ul>
<br/>
<br/>

<!-- Tasks done -->

<%= link_to_remote("Display done tasks",
   {:update => :tasksdone,
    :url =>{ :action => :display_tasks_done },
    :loading=>visual_effect('appear', 'loading2'),
    :success=>visual_effect('fade', 'loading2')},
   {:class=>'btnlnk', :id=>'done_link'})
%>
<img id="loading2" src="/images/loading.gif" style="display:none;">
<div id="tasksdone">
	<ul id="taskdoneul" class="mylist"></ul>
</div>
<%= sortable_element 'taskslist', :url => { :action => "order" } %>
<% end %>
